/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package util;
import com.hp.hpl.jena.query.*;

/**
 *
 * @author antonio
 */
public class ExecuteSparqlQuery {

    private Query cubixQuery;
    private ResultSet results;

    public ExecuteSparqlQuery(String query)
    {
        this.cubixQuery = QueryFactory.create(query);
    }

    public ResultSet connect()
    {
        QueryExecution qexec = QueryExecutionFactory.sparqlService("http://localhost:8890/sparql", this.cubixQuery);
        try{

            this.results = qexec.execSelect();
            /*
            while(results.hasNext())
            {
                QuerySolution soln = results.nextSolution();
                String uri = soln.get("persone").toString();
                System.out.println("person: " + uri);
            }
            */
        }finally{qexec.close();}

        return results;

    }


}
